package com.study.example.gameserver.module.base;

import com.sparrow.common.util.TimeUtil;
import com.sparrow.event.annotation.EventReceiver;
import com.sparrow.example_message.base.req.ReqHeatBeatPacket;
import com.sparrow.example_message.base.resp.RespHeatBeatPacket;
import com.sparrow.socket.tcp.anno.PacketHandler;
import com.sparrow.socket.tcp.session.impl.GameSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@PacketHandler
@Component
public class BaseController {

    private static Logger logger = LoggerFactory.getLogger(BaseController.class);

    @EventReceiver
    public void reqHeatBeat(GameSession session, ReqHeatBeatPacket req) {
        logger.info("session:{} 请求心跳", session.getId());
        RespHeatBeatPacket packet = new RespHeatBeatPacket();
        packet.setServerTime(TimeUtil.currentTimeMillis());
        session.write(packet);
    }

}
